Imports CapaDeDatos
Public Class nDetalleOrdenDePago
    Private TblDetalleOrdenDePago As dDetalleOrdenDePago = New dDetalleOrdenDePago()
    Private FacturaCompra As CapaDeNegocios.nFacturaCompra = New CapaDeNegocios.nFacturaCompra
    Private TblOrdendePago As dOrdendePago = New dOrdendePago()
    Public Function Insertar(ByVal Factura As String, ByVal Total As String, ByVal OrdenDePago As String) As Boolean
        Return TblDetalleOrdenDePago.Insertar(Factura, Total, OrdenDePago)
    End Function
    Public Function Eliminar(ByVal IdDetalleOrdenDePago As String, ByVal OrdenDePago As String) As Boolean
        Return TblDetalleOrdenDePago.Eliminar(IdDetalleOrdenDePago, OrdenDePago)
    End Function
    Public Function BuscarFiltrado(ByVal IdDetalleOrdenDePago As String, ByVal Factura As String, ByVal Total As String, ByVal OrdenDePago As String) As DataSet
        Dim dts As DataSet
        dts = TblDetalleOrdenDePago.BuscarFiltrado(IdDetalleOrdenDePago, Factura, Total, OrdenDePago)
        dts.Tables(0).Columns.Add("CodigoFactura")
        Dim i As Integer
        For i = 0 To dts.Tables(0).Rows.Count - 1
            Try
                dts.Tables(0).Rows(i)("CodigoFactura") = FacturaCompra.ListarFacturas(0, TblOrdendePago.BuscarFiltrado(dts.Tables(0).Rows(i)("OrdenDePago").ToString(), "", "", "", "").Tables(0).Rows(0)("IdProveedor").ToString(), dts.Tables(0).Rows(i)("Factura").ToString(), "CANCELADA", 0, 0, "", "").Tables(0).Rows(0)("CodigoFactura").ToString()
            Catch ex As Exception
                dts.Tables(0).Rows(i)("CodigoFactura") = ""
            End Try
        Next
        Return dts

    End Function

End Class
